﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExpensesServerSideBind.aspx.cs"
    Inherits="ExpensesServerSideBind"  Debug="true" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function rowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }

        </script>
    </telerik:RadCodeBlock>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <telerik:RadAjaxManager runat="server" ID="RadAjaxManager1">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="grdExpenses">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="grdExpenses" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        <telerik:AjaxUpdatedControl ControlID="RadInputManager1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Transparency="10"
            BackColor="White" InitialDelayTime="500">
            <asp:Image ID="Image1" Style="margin-top: 10px" runat="server" ImageUrl="~/loading.gif"
                BorderWidth="0px" AlternateText="Loading"></asp:Image>
        </telerik:RadAjaxLoadingPanel>
        <telerik:RadGrid runat="server" ID="grdExpenses" AutoGenerateColumns="false" AllowPaging="true"
            Skin="Vista" OnNeedDataSource="grdExpenses_NeedDataSource" OnInsertCommand="grdExpenses_InsertCommand"
            OnItemCommand="grdExpenses_ItemCommand" OnUpdateCommand="grdExpenses_UpdateCommand"
            OnDeleteCommand="grdExpenses_DeleteCommand">
            <MasterTableView DataKeyNames="ExpID" CommandItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage">
                <Columns>
                    <telerik:GridEditCommandColumn ButtonType="ImageButton" />
                    <telerik:GridBoundColumn DataField="ExpID" HeaderText="Exp ID" ForceExtractValue="Always"
                        ConvertEmptyStringToNull="true" UniqueName="ExpID" />
                    <telerik:GridBoundColumn DataField="Category" HeaderText="Category" UniqueName="Category" />
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="" />
                    <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" DataFormatString="{0:c}"
                        UniqueName="Description" />
                    <telerik:GridButtonColumn ConfirmText="Delete this Expense?" ConfirmDialogType="RadWindow"
                        ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" />
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <EditColumn ButtonType="ImageButton" />
                    <FormTemplate>
                        <table>
                            <tr>
                                <td>
                                    Exp ID :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtExpID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "ExpID")%>'
                                        Enabled='<%# (Container is GridEditFormInsertItem) ? Convert.ToBoolean("True") : Convert.ToBoolean("False") %>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Category :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtCategory" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Category")%>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Description :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtDescription" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description")%>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    Amount :
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAmount" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Amount")%>'></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                    </asp:Button>&nbsp;
                                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
            <PagerStyle Mode="NextPrevAndNumeric" />
            <ClientSettings>
                <ClientEvents OnRowDblClick="rowDblClick" />
            </ClientSettings>
        </telerik:RadGrid>
        <telerik:RadInputManager runat="server" ID="RadInputManager1" Enabled="true">
            <telerik:TextBoxSetting BehaviorID="TextBoxSetting1">
            </telerik:TextBoxSetting>
            <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting1" Type="Currency"
                AllowRounding="true" DecimalDigits="2">
            </telerik:NumericTextBoxSetting>
            <telerik:NumericTextBoxSetting BehaviorID="NumericTextBoxSetting2" Type="Number"
                AllowRounding="true" DecimalDigits="0" MinValue="0">
            </telerik:NumericTextBoxSetting>
        </telerik:RadInputManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" />
    </div>
    </form>
</body>
</html>
